//
//  NSString+md5.m
//  Community
//
//  Created by litengfei on 14/11/13.
//  Copyright (c) 2014年 90's Technology Co.Ltd. All rights reserved.
//

#import "NSString+md5.h"
#import <CommonCrypto/CommonDigest.h>

@implementation NSString (md5)
- (NSString*)md5
{
    const char* str = [self UTF8String];
    unsigned char hash[16];
    CC_MD5(str, (CC_LONG)strlen(str), hash);
    NSMutableString* result = [NSMutableString string];
    for (int i = 0; i < 16; ++i) {
        [result appendFormat:@"%02x", hash[i]];
    }
    return result;
}
@end
